
import myexchange.CardService;
import myexchange.Exchange;
import myexchange.GameService;
import myexchange.Player;
import myexchange.Share;
import myexchange.Game

class BootStrap {
	
	GameService gameService;
	
    def init = { servletContext ->
		
		println "#"*10 + " Creating Players " + "#"*10
		Player vovik = new Player(userName:"vovik", password:"test", firstName:"Waldemar", lastName:"Schäfer", nickname:"Vovik", cash:1000).save(failOnError: true);
		Player a = new Player(userName:"vr33", password:"test", firstName:"Vitalik", lastName:"Ritter", nickname:"VR33", cash:1000).save(failOnError: true);
		Player q = new Player(userName:"jura", password:"test", firstName:"Georg", lastName:"Schlegel", nickname:"Jura",cash:1000).save(failOnError: true);
		Player tester = new Player(userName:"tatjana", password:"test", firstName:"Tatjana", lastName:"Schäfer", nickname:"Swesda", cash:1000).save(failOnError: true);
		
		println "#"*10 + " Creating Shares " + "#"*10
		Share bmw = new Share(name:"BMW",price:100).save(failOnError: true);
		Share coba = new Share(name:"CoBa").save(failOnError: true);
		Share bp = new Share(name:"BP",price:100).save(failOnError: true);
		Share bayer = new Share(name:"Bayer").save(failOnError: true);
//		
//		println "#"*10 + " Initializing Exchange " + "#"*10
//		new Exchange(player:vovik,share:bmw,quantity:10).save(failOnError: true);
//		new Exchange(player:a,share:coba,quantity:11).save(failOnError: true);
//		new Exchange(player:vovik,share:bp,quantity:10).save(failOnError: true);
//		new Exchange(player:q,share:bmw,quantity:20).save(failOnError: true);
//		new Exchange(player:tester,share:bayer,quantity:10).save(failOnError: true);
//		new Exchange(player:tester,share:bp,quantity:5).save(failOnError: true);
//		
//		println "#"*10 + " Starting game " + "#"*10
		Game g = gameService.startGame()
    }
    def destroy = {
    }
}
